#include "nr_client_login_dialog.h"
#include <QString>
#include <QMessageBox>
#include "nr_client_mainwindow.h"
#include "nr_client_communication.h"
#include "nr_client_config_manager.h"


logindlg::logindlg(QWidget *parent)
	: QDialog(parent)
{
//	m_devicetree = devicetree;
	ui.setupUi(this);
/*	config->load();*/

/*	ui.leusername->setText()*/
}

logindlg::~logindlg()
{

}

void logindlg::on_pblogin_clicked()
{
	if(ui.leusername->text().isEmpty()||ui.lepassword->text().isEmpty())
	{
		QMessageBox::information(this,tr("Attention!"),tr("Please check your input message!"),QMessageBox::Ok);
		return;
	}
	QString username = ui.leusername->text();
	QString password = ui.lepassword->text();

	/////////////////////////////////
	if((username=="123")&&(password=="123"))
	{
	/*	index *mainForm; //example;
		mainForm = new index();
		mainForm->show();
		this->hide();*/

		//nr_device_item_server *itemserver = m_devicetree->get_device_item_server();
		client_Communication* c = new client_Communication(this);
		c->login();

		mainwindow* w ;
		w = new mainwindow();
		w->set_CommunicationToServer(*c);
		w->show();
		this->hide();		
	}
	else
	{
		QMessageBox::warning(this,tr("Attention!"),tr("Please check username and password!"),QMessageBox::Ok);
		ui.lepassword->clear();
		ui.leusername->clear();
		ui.leusername->setFocus();
	}
}
